#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QCamera>
#include <QCameraViewfinder>
#include <QCameraImageCapture>
#include <QCameraInfo>
#include <QMediaRecorder>
#include <QList>
#include <QDebug>

#include <QImage>
#include "ffmpegwindow.h"
namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow {
    Q_OBJECT

public:

    explicit MainWindow(QWidget *parent = nullptr);
    ~MainWindow();

protected:

    void run();

private slots:

    void quitApp();
    void initWindow();
    void setCamera(const QCameraInfo& cameraInfo);
    void on_pushButtonOpenCam_clicked();
    void captureImage();
    void saveImage();
    void displayImage(int,
                      QImage image);
    void on_pushButtonPlay_clicked();
    void showVideo();
    void bindRecoder(QCamera *cameraList);
    void startRecord();
    void updateRecordTime();
    void pauseRecord();
    void stopRecord();
    void saveVideo();
    void on_pushButtonCaptureImage_clicked();

    void on_pushButtonSaveImage_clicked();

    void on_pushButtonBeginRecord_clicked();

    void on_pushButtonEndRecord_clicked();

    void on_pushButtonSaveVideo_clicked();


    void on_pushButtonOpenFFmpeg_clicked();

    void on_pushButtonCloseCam_clicked();

    void on_pushButtonDetect_clicked();

    void on_comboBoxSelectCam_currentIndexChanged(const QString& arg1);

private:

    Ui::MainWindow *ui;


    //    QScopedPointer<QCamera> camera;
    //    QScopedPointer<QCameraImageCapture> imageCapture;
    //    QScopedPointer<QMediaRecorder> mediaRecorder;
    FFmpegWindow ffmpegWindow;
    QImageEncoderSettings m_imageSettings;
    QAudioEncoderSettings m_audioSettings;
    QVideoEncoderSettings m_videoSettings;
    QMediaRecorder *m_mediaRecorder;
    QCamera *m_camera;

    QList<QCamera *>cameraList;

    QCameraImageCapture *imageCapture;
    QPixmap *pixmap;
    QCameraInfo *caminfo;
    QCameraViewfinder *viewfinder;
    QString getDeviceNamge(int id);
    QCameraViewfinderSettings *viewfinderSettings;
};

#endif // MAINWINDOW_H
